<%
Class Link
'Catelog

private ThisMdb		'=	"L_cat"				'数据库
private sqlstr
'-------------------------------------------
Property Get PThisMdb
	PThisMdb=ThisMdb
End Property
Property Let PThisMdb(catMdb)
	ThisMdb=catMdb
End Property
'
'-------------------
public Function AddNew(arrs)				'传入一维数组
	if not isarray(arrs) then 
		AddNew = false
		exit Function
	End if
'		sqlstr ="insert into  "&ThisMdb&"([link_title],[link_url],[link_level],[link_logo]) values('"&arrs(1)&"',"&arrs(2)&","&arrs(3)&",'"&arrs(4)&"')"
'		on error resume next
'		conn.execute(sqlstr)
'		If Err Then
'			response.write (err.Description)
'			response.write (sqlstr)
'			err.Clear
'			AddNew = false 
'		else
'			AddNew = true
'		End if

	on error resume next
	Dim adors
	set adors=server.createobject("adodb.recordset")
	sqlstr ="select top 1 * from "&ThisMdb&" "
	adors.open sqlstr,conn,1,3
	'if not  adors.eof then 
		adors.addnew
		adors("link_title")			=	arrs(1)
		adors("link_url")			=	arrs(2)
		adors("link_level")			=	arrs(3)
		adors("link_logo")			=	arrs(4)
		adors.update 
	'End if 
		If Err Then
			response.write (err.Description)
			err.Clear
			AddNew = false 
		else
			AddNew = true
		End if
	adors.close
	Set adors=nothing 

End Function
public Function Delete(link_id)
		sqlstr="delete from  "&ThisMdb&"  where [link_id]="&link_id&""
		on error resume next
		conn.execute(sqlstr)
		If Err Then
			response.write (err.Description)
			err.Clear
			Delete = false 
		else
			Delete = true
		End if

End Function 
'---------------------
public Function GetCatAll()
	sqlstr = "select [link_id],[link_title],[link_url],[link_level],[link_logo] from "&ThisMdb&" order by [link_level] asc"
	GetCatAll = GetRows(sqlstr)
End Function 

public Function GetById(ids)
	sqlstr="select [link_id],[link_title],[link_url],[link_level],[link_logo] from "&ThisMdb&" where [link_id]="&ids&" order by [link_level] desc"
	GetById =  GetRows(sqlstr) 
End Function 

public Function Edit(arrs)
	if not isarray(arrs) then 
		AddNew = false
		exit Function
	End if

	on error resume next
	Dim adors
	set adors=server.createobject("adodb.recordset")
	sqlstr ="select top 1 * from "&ThisMdb&" where [link_id]="&arrs(0)&" "
	adors.open sqlstr,conn,1,3
	if not(adors.eof and adors.bof) then 
		adors("link_title")			=	arrs(1)
		adors("link_url")			=	arrs(2)
		adors("link_level")			=	arrs(3)
		adors("link_logo")			=	arrs(4)
		adors.update 
	End if 
		If Err Then
			response.write (err.Description)
			err.Clear
			Edit = false 
		else
			Edit = true
		End if
	adors.close
	Set adors=nothing 
End Function 

'---------------------
private Function Exist(arrs,str)
	Dim ai,booltf
	booltf = false 
	if isarray(arrs) then 
		for ai=0 to ubound(arrs,2)				'2维数组
			if str = arrs(0,ai) then 
				booltf = true 
			End if
		next 
	else
			if str = arrs then 
				booltf = true 
			End if
	End if
	Exist =	booltf
End Function 
'-------------------------------------------
End class
%>